package com.hzdl.utils;

import com.hzdl.common.Constants;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: bxc
 * @date: 2018/9/5 0005
 * @description: 获取当前日期类
 */
public class DateUtils {

    //获取当前时间
    public static String getNowTime() {
        SimpleDateFormat syDateFormat=new SimpleDateFormat(Constants.YYYY_MM_DD);
        Date date=new Date();
        String time=syDateFormat.format(date);
        return time;
    }

    //字符串转Date类型
    public static Date convert(String s) {
        SimpleDateFormat sdf = new SimpleDateFormat(Constants.YYYY_MM_DD);
        Date date = null;
        try {
            date = sdf.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
    //date转字符串
    public static String simpDF(Date date){
        SimpleDateFormat sdf = new SimpleDateFormat(Constants.YYYY_MM_DD);
        String s="";

            s = sdf.format(date);

        return s;
    }

}
